/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package FrameWork;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.Sprite;

/**
 *
 * @author ThanhTri
 */
public class ItemMenu {
    protected int       m_CurIndex;
    protected int       m_NextIndex;
    protected float     m_x,m_y;
    protected String    m_Str;
    protected Sprite    m_Button;
    protected int       m_ID;
    protected MySpriteFont m_font;
    
    public int getCurIndex () {
        return m_CurIndex;
    }
    public int getNextIndex () {
        return m_NextIndex;
    }
    public void setCurIndex (int _Cur){
        m_CurIndex = _Cur;
    }
    public void setNextIndex (int _Next){
        m_NextIndex = _Next;
    }
    public void setString (String _Str){
        m_Str = _Str;
    }
    public String getString () {
        return m_Str;
    }
    public boolean getReady (){
        return (m_CurIndex == m_NextIndex);
    }
    public int getID (){
        return  m_ID;
    }
    
    public ItemMenu (){
        m_CurIndex  = 0;
        m_NextIndex =   0;
        m_x         = 0;
        m_y         =0;
        m_Str       = "";
        m_ID        =0;
    }
    public ItemMenu (int _Index,int _ID,String _Str,
            MySpriteFont _Font, Sprite _button){
        m_CurIndex  = _Index;
        m_NextIndex = _Index;
        m_x         = 0;
        m_y         = m_NextIndex* 40 + 60 ;
        m_Str       = _Str;
        m_Button    = _button;
        m_ID        = _ID;
        m_font      = _Font;
    }
    public void Update (float _Time){
                
        if (m_CurIndex>m_NextIndex){
            m_y -= 100 * _Time;
            if (m_y < m_NextIndex* 40 + 60){
                if (m_NextIndex == -1){
                     m_NextIndex =4;
                }   
                m_CurIndex =m_NextIndex;
                m_y =  m_NextIndex* 40 + 60;
            }
        }
        
        if (m_CurIndex < m_NextIndex){
            m_y += 100 * _Time;
            if (m_y > m_NextIndex* 40 + 60){
                if (m_NextIndex == 5){
                     m_NextIndex =0;
                }
                m_CurIndex =m_NextIndex;
                m_y =  m_NextIndex* 40 + 60;
            }
        }
    }
    public void Render (Graphics _Graphics){
        m_Button.setPosition((int)m_x, (int)m_y);
        m_Button.paint(_Graphics);
        
        m_font.DrawString(m_Str, 80, (int)m_y+12, _Graphics);
    }
}
